var core    = require('core')
,   tools   = core.tools
,   error   = core.error
,   success = core.success
,   auth    = core.auth;

module.exports = function(req, res, next){
    auth.login({
        name : req.body.name || req.query.name,
        pwd  : tools.sha1(req.body.pwd  || req.query.pwd),
        type : "merchant"
    }, function(err, token){
        if(err)
            return res.send(err);

        var rdata = success();
        rdata.data = token;

        res.send(rdata);

    });

};